{% extends 'base.html' %}
{% load customer_tags %}
{% block title %}{{ section }}页{% endblock %}
{% block section %}{{ section }}{% endblock %}
{% block content %}
    <form class="forms-sample" method="post">
        {% csrf_token %}

        {% for field in form %}
            <div class="form-group row">
                <label for="{{ field.id_for_label }}" class="col-sm-3 col-form-label">{{ field.label }}</label>
                <div class="col-sm-5">
                    {#                      {{ field }}#}
                    {% if field.label != '性别' %}
                    {% add_class field 'form-control' %}
                    {% else %}
                    {{ field }}
                    {% endif %}
                </div>
                {% for error in field.errors %}
                    <label for="{{ field.id_for_label }}" class="col-sm-3 col-form-label">{{ error }}</label>
                {% endfor %}
            </div>
        {% endfor %}
        {#        {{ form.as_p }}#}
        {#        {{ detail_form.as_p }}#}
        {% for field in detail_form %}
            <div class="form-group row">
                <label for="{{ field.id_for_label }}" class="col-sm-3 col-form-label">{{ field.label }}</label>
                <div class="col-sm-5">
                    {#                      {{ field }}#}
                    {% add_class field 'form-control' %}
                </div>
                {% for error in field.errors %}
                    <label for="{{ field.id_for_label }}" class="col-sm-3 col-form-label">{{ error }}</label>
                {% endfor %}
            </div>
        {% endfor %}

        {% if section == '学生详情' %}
            <a class="btn btn-primary me-2" href="{% url 'students:list' %}">返回</a>
        {% else %}
            <button type="submit" class="btn btn-primary me-2">提交</button>
            <button type="reset" class="btn btn-light">重置</button>
        {% endif %}
    </form>
{% endblock %}


